package com.xy.smartsms.adapter;

import android.content.Context;

import com.example.messageutil.iface.IMenuProcessor;
import com.example.messageutil.iface.IMessageProcessor;
import com.example.messageutil.iface.ISmartSMSProcessor;
import com.xy.smartsms.app.plugin.BuildConfig;
import com.xy.smartsms.facade.SmsProcessFacade;

import java.util.concurrent.ConcurrentHashMap;

import cn.cmcc.online.smsapi.sdk.constant.Constant;
import cn.cmcc.online.smsapi.sdk.log.LogManager;
import cn.cmcc.online.smsapi.ui.manager.CardViewFactory;


/**
 * Created by admin on 2017/9/1 0001.
 */

public class XySmartSMSProcessor implements ISmartSMSProcessor {
    @Override
    public void init(Context context) {
        ConcurrentHashMap<String, String> extend = new ConcurrentHashMap<>();
        //是否支持在线升级sdk 0:不支持 1:支持(默认)
        extend.put(Constant.ONLINE_UPDATE_SDK, "1");
        //增强开关 是否允许网络请求
        extend.put(Constant.SMARTSMS_ENHANCE, "true");
        //支持的网络类型 不影响小流量请求 0:不支持 1:wifi 2:数据网络和wifi
        extend.put(Constant.SUPPORT_NETWORK_TYPE, "2");

        //渠道密钥
        extend.put(Constant.CHANNEL, BuildConfig.DUOQU_SDK_CHANNEL);
        extend.put(Constant.SECRETKEY, BuildConfig.DUOQU_SDK_CHANNEL_SECRETKEY);
        //RSA渠道密钥
        extend.put(Constant.RSAPRVKEY, BuildConfig.DUOQU_SDK_RSAKEY);
        extend.put(Constant.CONFIG_APPKEY, "CMCCONLINE"); //
        SmsProcessFacade.getInstance(context).init(new XySdkAction(), extend);
        CardViewFactory.getInstance(context, DataExchangeImpl.getInstance(context));
        LogManager.debug = true;
        com.xy.smartsms.util.Log.level = com.xy.smartsms.util.Log.DEBUG;
    }

    @Override
    public IMessageProcessor loadMessageProcessor() {
        return new XyMessageProcessor();
    }

    @Override
    public IMenuProcessor loadMenuProcessor() {
        return new XyMenuProcessor();
    }
}
